<template>
  <div class="blog-demo demo-wrapper">
    <div class="demo-item" @click="goBirdDemo" v-loading="birdLoading">
      <el-card shadow="hover">
        <img src="~@/assets/img/bird/birdHome.png" />
        <div class="descrition">
          <p>以ES6类的编码方式完成的像素鸟游戏</p>
        </div>
      </el-card>
    </div>
    <div class="demo-item" @click="goRainDemo" v-loading="rainLoading">
      <el-card shadow="hover">
        <img src="~@/assets/img/rain/rainHome.png" />
        <div class="descrition">
          <p>以canvas编写的下雨效果</p>
        </div>
      </el-card>
    </div>
    <div class="demo-item" @click="goImgDemo" v-loading="imgLoading">
      <el-card shadow="hover">
        <img src="~@/assets/img/imgWall/index.jpg" />
        <div class="descrition">
          <p>以css3实现的照片墙</p>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
export default {
  mounted() {
    this.birdLoading = false
    this.rainLoading = false
    this.imgLoading = false
  },
  data() {
    return {
      birdLoading: true,
      rainLoading: true,
      imgLoading: true
    }
  },
  methods: {
    goBirdDemo() {
      this.$router.push({ name: 'demo-bird' })
    },
    goRainDemo() {
      this.$router.push({ name: 'demo-rain' })
    },
    goImgDemo() {
      this.$router.push({ name: 'demo-img' })
    }
  }
}
</script>

<style lang="scss">
.blog-demo {
  &.demo-wrapper {
    display: flex;
    flex-wrap: wrap;
    width: 1190px;
    margin: 0 auto;
    border-radius: 10px;
    .demo-item {
      padding: 10px;
      box-sizing: border-box;
      height: 300px;
      width: 50%;
      box-sizing: border-box;
      cursor: pointer;

      .el-card {
        width: 100%;
        height: 100%;
        overflow: hidden;
        border: none;
        .el-card__body {
          position: relative;
          width: 100%;
          height: 100%;
          box-sizing: border-box;
          img {
            width: 100%;
            height: 100%;
            object-fit: contain;
          }
        }
        .descrition {
          position: absolute;
          bottom: 0;
          left: 0;
          height: 50%;
          width: 575px;
          box-sizing: border-box;
          background-color: rgba(100, 100, 100, 0.5);
          color: #fff;
          text-align: center;
          line-height: 30px;
        }
      }
    }
  }
}
</style>
